<?php
/**
 * Created by PhpStorm.
 * User: Soha_Ros
 * Date: 17/5/26
 * Time: 下午4:00
 */

namespace ActionsHttp;

use Data\Food_groups_DAO;

class RestaurantFoodGroupsDelete extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();

        // 商铺id
        $restaurant_id = $_SESSION[RESTAURANT_ID];
        $restaurant_id = 1;


        // 分类ID
        $groups_id = $this->data[FOOD_GROUP_ID];

        $groups_record = Food_groups_DAO::getRecord($groups_id);

        if (!$groups_record) {
            // 没有该分类
            return $this->SendErrMsg("没有该分类");
        }

        if ($groups_record->getRESTAURANT_ID() != $restaurant_id) {
            // 非法操作
            return $this->SendErrMsg("非法操作");
        }

        // 删除
        Food_groups_DAO::deleteById($groups_id);

        // 返回数据
        $this->ResponseDataToCurrentClient();
    }
}